package business.command
{
	import business.modelLocators.ProductModelLocator;
	import business.service.delegate.BusinessAMDelegate;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	public class GetAllProductsCommand implements ICommand, IResponder
	{
		public function GetAllProductsCommand()
		{
		}
		public function execute(event:CairngormEvent):void {
			var businessAMDelegate:BusinessAMDelegate = new BusinessAMDelegate(this);
			businessAMDelegate.getAllProducts();
		}
		public function fault(info:Object):void {
			Alert.show("GetAllProductsCommand fault exeucted");
		}
		public function result(result:Object):void {
			var model:ProductModelLocator = ProductModelLocator.getInstance();
			model.allProducts = result.result as ArrayCollection;
			Alert.show("The total num of products is: "+model.allProducts.length.toString());
		}

	}
}